import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'
Vue.use(VueRouter)

const routes = [
   {
     path: '/',
     name: 'Index',
     redirect: { name: 'BlogList' }
  },
  {
    path: '/',
    name: 'Main',
    component: Main,
    children:[
        {
          path: 'login',
          name: 'Login',
          component: () => import('../views/Login.vue'),
         
        },
        {
          path: 'blogs',
          name: 'Blogs',
          // 懒加载
          component: () => import('../views/Blogs.vue'),
          children:[    
          {
            path: 'add', // 注意放在 path: '/blog/:blogId'之前
            name: 'BlogAdd',
            meta: {
              requireAuth: true
            },
            component: () => import('../views/BlogEdit.vue'),
            mata: {
              requireAuth: true 
           }
          },
          {
            path: 'list',
            name: 'BlogList',
            meta: {
              requireAuth: true
            },
            component: () => import('../views/BlogList.vue'),
            mata: {
              requireAuth: true 
           }
          },
          {
            path: ':blogId',
            name: 'BlogDetail',
            component: () => import('../views/BlogDetail.vue'),
            mata: {
              requireAuth: true 
           }
           
          },
          {
            path: ':blogId/edit',
            name: 'BlogEdit',
            component: () => import('../views/BlogEdit.vue'),
            mata: {
              requireAuth: true 
           }
          }]
        }, 
    
    ]
  },

 
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})


export default router
